/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-01-12 09:35:49
 * @LastEditTime : 2023-05-25 09:21:54
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Modal\TwoModalList\Organization.jsx
 * @Description  :
 */

import { API_LIST } from '../../Api/Api'
import { commonTableList } from '../config'
import { TwoAddBtn, ThrDeleteBtn } from '../options'

export const Organization = async ({ upDataEvent, data, Permission }) => {
    let dataList = {
        type: '机构从属管理',
        hideInSearch: true,
        pageSize: 10,
        params: {},
        classification: 'TableModal',
        get: API_LIST([data.uuid])['getOrganizationRelationGetOrgListByParentOrgUuid'],
        additional: { key: 'ParentOrganizationUuid', value: 'uuid' },
        options: [
            Permission.findIndex(v => v.uuid === 'c9694e0b-760c-4ff8-823e-80ebe4460703') !== -1 && (
                <TwoAddBtn
                    upDataEvent={upDataEvent}
                    title="添加下级机构"
                    ThrKey="ThrModal"
                    value="Organization"
                    data={data}
                />
            ),
        ],
        columns: [
            { ...commonTableList.tableName, title: '组织机构' },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 220,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '1506d480-fb0a-4ff5-bb93-14e4f72e5946') !== -1 && (
                            <ThrDeleteBtn
                                key="delete"
                                record={record.uuid}
                                upDataEvent={upDataEvent}
                                data={{ key: 'delete', url: 'delOrganizationRelation', title: '删除从属机构' }}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return dataList
}
